package com.budgetme.activities;

import android.app.Activity;
import android.content.ContentValues;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

import com.budgetme.R;
import com.budgetme.database.Database;


public class AddIncome extends Activity implements OnClickListener {
	private static final String TAG = AddIncome.class.getName();
	
	EditText mIncomeNameInput;
	EditText mIncomeAmountInput;
	Button mSubmit;
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
        Log.d(TAG, "onCreate");

		setContentView(R.layout.add_income);
		
		mIncomeNameInput = (EditText) findViewById(R.id.add_income_name);
		mIncomeAmountInput = (EditText) findViewById(R.id.add_income_amount);
		mSubmit = (Button) findViewById(R.id.add_income_submit);
		
		mSubmit.setOnClickListener(this);
		
	}

	@Override
	public void onClick(View v) {
		
		Uri uri = Database.tbl_income.CONTENT_URI;
		
		ContentValues values = new ContentValues();
		values.put(Database.tbl_income.i_name, mIncomeNameInput.getText().toString());
		values.put(Database.tbl_income.i_amount, mIncomeAmountInput.getText().toString());
		
		getContentResolver().insert(uri, values);
		
	}
	
	@Override
	public void onDestroy() {
		super.onDestroy();
		Log.d(TAG, "onDestroy");
	}
	
	@Override
	public void onPause() {
		super.onPause();
		Log.d(TAG, "onPause");
	}
	
	@Override
	public void onResume() {
		super.onResume();
		Log.d(TAG, "onResume");
	}

}
